package com.arpa.ntocc.basic.api.controller;


import com.arpa.core.web.Result;
import com.arpa.ntocc.common.common.Page;
import com.arpa.ntocc.common.common.constant.StrConsts;
import com.arpa.ntocc.common.controller.BaseController;
import com.arpa.ntocc.common.domain.vo.AreaCountryProvinceVO;
import com.arpa.ntocc.common.domain.vo.AreaProvinceVO;
import com.arpa.ntocc.common.service.IAreaCountryService;
import io.swagger.annotations.*;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 国家信息表 Controller
 * </p>
 *
 * @author LEO
 * @since 2019-12-04
 */
@Api(tags = "国家信息表")
@RestController
@RequestMapping(value="/areaCountry", produces = "application/json;charset=UTF-8")
@Log4j2
public class AreaCountryController extends BaseController {


   private final IAreaCountryService iAreaCountryService;

    public AreaCountryController(IAreaCountryService iAreaCountryService) {
        this.iAreaCountryService = iAreaCountryService;
    }


    /**
     * 获取 省市县三级全部数据 列表
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "获取国家省市县四级全部数据 列表", notes = "获取国家省市县四级全部数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "授权token", required = true, paramType = "header", dataType = "String", defaultValue = "Bearer "),
            @ApiImplicitParam(name = "deviceId", value = "设备id", paramType = "header", dataType = "string", defaultValue = "0000000000")
    })
    @ApiResponses(@ApiResponse(code = 0, message = "success", response = AreaProvinceVO.class))
    @GetMapping("/queryList")
    public Result queryAllList(HttpServletRequest request) {
        try {
            List<AreaCountryProvinceVO> areaProvinceVOList = this.iAreaCountryService.queryCountryProvinceList();
            Page returnPage = new Page();
            returnPage.setRecords(areaProvinceVOList);
            return Result.ok().data(returnPage);
        } catch (Exception e) {
            log.error(StrConsts.CATCH_MESSAGE,e);
            return Result.error(e.getMessage());
        }
    }



 }
